using System;
using System.Text;
using System.CodeDom;
using System.CodeDom.Compiler;

using FrameworkX.ObjectSpace;
using FrameworkX.ObjectSpace.Data.Schema;
using Microsoft.CSharp;

namespace FrameworkX.ObjectSpace.Util
{
	/// <summary>
	/// This class is not used now. Its for future use.
	/// </summary>
	public class ConcretePopulatorBuilder
	{
		private Type _type;
		private ObjectSchema _schema;

		private const string POPULATOR_SUFFIX = "Populator";

		public ConcretePopulatorBuilder(Type type, ObjectSchema schema)
		{
			_type = type;
			_schema = schema;
		}

		public IPopulateObject GetPopulator ()
		{

			return null;
//			CSharpCodeProvider csp = new CSharpCodeProvider ();
//			ICodeCompiler compiler =  csp.CreateCompiler();
//			CompilerParameters parms = new CompilerParameters();
//			parms.OutputAssembly = "Enterprise.ObjectSpace.RuntimeObjects";
//			parms.GenerateInMemory = true;
//			parms.IncludeDebugInformation = false;
//			parms.ReferencedAssemblies.Add("System.dll");
//			parms.ReferencedAssemblies.Add("System.Data.dll");
//			parms.ReferencedAssemblies.Add("System.Xml.dll");
//			parms.ReferencedAssemblies.Add("Enterprise.Core.dll");
//			parms.ReferencedAssemblies.Add("Enterprise.ObjectSpace.dll");
//			
//			CompilerResults results =  compiler.CompileAssemblyFromDom (parms,ccu);
//		
//			if (results.Errors.Count>0)
//			{
//				return null;
//			}
//
//			Type generatedType= results.CompiledAssembly.GetType("Enterprise.ObjectSpace.RuntimeObjects." + _type.Name + POPULATOR_SUFFIX);
//			return (IPopulateObject) Activator.CreateInstance(generatedType);
						
		}
	}
}
